package servidor;

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import clasesBasicas.Usuario;
import java.awt.CardLayout;

public class VentanaServidor extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	public static PanelPrincipal panelPrincipal;
	public static PanelUsuarios panelUsuarios;
	public static PanelAnadirUsuario panelAnadir;
	public static PanelEditarUsuario panelEditar;
	public static PanelVariables panelVariables;
	public static PanelAnadirAccion panelAnadirAccion;
	public static GestorBDUsuarios bdUsers;
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			@Override
			public void run() {
				try {
					VentanaServidor frame = new VentanaServidor();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public VentanaServidor() {
		setTitle(".:: Administrador del Servidor ::.");
		setBounds(100, 100, 615, 525);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new CardLayout(0, 0));
		bdUsers = new GestorBDUsuarios();
		
		panelPrincipal = new PanelPrincipal();
		panelUsuarios = new PanelUsuarios();
		panelAnadir = new PanelAnadirUsuario();
		panelEditar = new PanelEditarUsuario();
		panelVariables = new PanelVariables();
		panelAnadirAccion = new PanelAnadirAccion();
		
		this.add(panelPrincipal);
		this.add(panelUsuarios);
		this.add(panelAnadir);
		this.add(panelEditar);
		this.add(panelVariables);
		this.add(panelAnadirAccion);
		
		panelPrincipal.setVisible(true);
		panelUsuarios.setVisible(false);
		panelAnadir.setVisible(false);
		panelEditar.setVisible(false);
		panelAnadirAccion.setVisible(false);
		
		setLocationRelativeTo(null);
		setVisible(true);
//		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	public static void irPanelUsuarios(){
		panelAnadir.setVisible(false);
		panelVariables.setVisible(false);
		panelEditar.setVisible(false);
		panelPrincipal.setVisible(false);
		panelAnadirAccion.setVisible(false);
		panelUsuarios.setVisible(true);
		
	}
	public static void volverPanelUsuarios(){
		panelAnadir.setVisible(false);
		panelEditar.setVisible(false);
		panelUsuarios.setVisible(false);
		panelVariables.setVisible(false);
		panelAnadirAccion.setVisible(false);
		panelPrincipal.setVisible(true);
	}
	public static void irPanelEditar(Usuario u){
		panelAnadir.setVisible(false);
		panelPrincipal.setVisible(false);
		panelUsuarios.setVisible(false);
		panelVariables.setVisible(false);
		panelAnadirAccion.setVisible(false);
		panelEditar.setVisible(true);
		panelEditar.setValores(u);
	}
	public static void volverPanelEditar(){
		panelAnadir.setVisible(false);
		panelPrincipal.setVisible(false);
		panelEditar.setVisible(false);
		panelVariables.setVisible(false);
		panelAnadirAccion.setVisible(false);
		panelUsuarios.setVisible(true);
	}
	public static void irPanelAnadir(){
		panelEditar.setVisible(false);
		panelPrincipal.setVisible(false);
		panelUsuarios.setVisible(false);
		panelVariables.setVisible(false);
		panelAnadirAccion.setVisible(false);
		panelAnadir.setVisible(true);
	}
	public static void volverPanelAnadir(){
		panelEditar.setVisible(false);
		panelPrincipal.setVisible(false);
		panelAnadir.setVisible(false);
		panelVariables.setVisible(false);
		panelAnadirAccion.setVisible(false);
		panelUsuarios.setVisible(true);
	}
	
	public static void irPanelVariables(){
		panelEditar.setVisible(false);
		panelAnadir.setVisible(false);
		panelPrincipal.setVisible(false);
		panelUsuarios.setVisible(false);
		panelAnadirAccion.setVisible(false);
		panelVariables.setVisible(true);
		
	}
	
	public static void volverPanelVariables(){
		panelEditar.setVisible(false);
		panelAnadir.setVisible(false);
		panelVariables.setVisible(false);
		panelUsuarios.setVisible(false);
		panelAnadirAccion.setVisible(false);
		panelPrincipal.setVisible(true);
	}
	public static void irPanelAnadirAccion(){
		panelEditar.setVisible(false);
		panelAnadir.setVisible(false);
		panelPrincipal.setVisible(false);
		panelUsuarios.setVisible(false);
		panelVariables.setVisible(false);
		panelAnadirAccion.setVisible(true);
	}
	
	public static void volverPanelAnadirAccion(){
		panelEditar.setVisible(false);
		panelAnadir.setVisible(false);
		panelUsuarios.setVisible(false);
		panelAnadirAccion.setVisible(false);
		panelPrincipal.setVisible(false);
		panelVariables.setVisible(true);
	}
	

}
